<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../../../assets/docs.css" rel="stylesheet" type="text/css" media="screen" />
<title>MooTools 1.3 Documentation - Types/Date.Extras</title>
</head>

<body>
  <div class="doc">
    <div class="methods">
      <h4 class="menu-item"><a href="#Date">Date</a></h4>
      <div class="menu-item"><a href="#Date:parsers">parsers</a></div>
      <div class="menu-item"><a href="#Date:timeDiff">timeDiff</a></div>
      <div class="menu-item"><a href="#Date:timeDiffInWords">timeDiffInWords</a></div>
    </div>
    <div class="l-border r-border span-15 content">
      <h1 id="Date"><a href="#Date">Type Date</a></h1>
      <p class="description">Extends the <em>Date</em> Type to include more powerful parsing and formatting functions; this is a further extention and depends on <em><a href="../../../docs/more/Types/Date.html">Date.js</a></em>.</p>
      <h3>Authors</h3>
      <ul>
        <li>Nicholas Barthelemy - https://svn.nbarthelemy.com/date-js/</li>
        <li>Harald Kirshner - mail [at] digitarald.de ; http://digitarald.de</li>
        <li>Aaron Newton - aaron [dot] newton [at] cnet [dot] com</li>
        <li>Scott Kyle - scott [at] appden.com; http://appden.com</li>
      </ul>
      <h3>Tutorial/Demo</h3>
      <ul>
        <li><a href="http://www.clientcide.com/wiki/cnet-libraries/03-native/01-date.extras">Online Tutorial/Demo</a></li>
      </ul>
      <h3>License</h3>
      <p>MIT-style license</p>
      <h2 id="Date:parsers"><a href="#Date:parsers"> Extra Date Parsers:</a></h2>
      <p class="description">In addition to the two default parsers included in <em><a href="../../../docs/more/Types/Date.html">Date.js</a></em>, <em>Date.Extras.js</em> includes some additional parsers.</p>
      <h3>Examples</h3>
      <pre class="javascript">Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'today'</span><span class="br0">)</span> <span class="co1">//"Mon Dec 10 2007 00:00:00 GMT-0800 (Pacific Standard Time)"</span>
Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'tomorrow'</span><span class="br0">)</span> <span class="co1">//"Tue Dec 11 2007 00:00:00 GMT-0800 (Pacific Standard Time)"</span>

Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'yesterday'</span><span class="br0">)</span> <span class="co1">//"Sun Dec 09 2007 00:00:00 GMT-0800 (Pacific Standard Time)"</span>
Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'next monday'</span><span class="br0">)</span> <span class="co1">//"Mon Dec 17 2007 00:00:00 GMT-0800 (Pacific Standard Time)"</span>
Date.<span class="me1">parse</span><span class="br0">(</span><span class="st0">'last wednesday'</span><span class="br0">)</span> <span class="co1">//"Wed Dec 05 2007 00:00:00 GMT-0800 (Pacific Standard Time)"</span>

</pre>
      <h3>See Also</h3>
      <ul>
        <li><a href="../../../docs/more/Types/Date.html#Date:parse">Date:parse</a></li>
      </ul>
      <h2 id="Date:timeDiff"><a href="#Date:timeDiff">Date Method: timeDiff</a></h2>
      <p class="description">Returns the difference between two dates in a compact format.</p>
      <h3>Syntax</h3>
      <pre class="javascript">date.<span class="me1">timeDiff</span><span class="br0">(</span><span class="br0">[</span>otherDate, joiner<span class="br0">]</span><span class="br0">)</span>;
</pre>
      <h3>Arguments</h3>
      <ol>
        <li>otherDate - (<em>date</em>) the date to compare to; defaults to the current time.</li>
        <li>joiner - (<em>string</em>) the string to join the values; defaults to ':'.</li>
      </ol>
      <h3>Example</h3>
      <pre class="javascript"><span class="kw2">var</span> example = <span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>;
example.<span class="me1">timeDiff</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//0s</span>

example.<span class="me1">decrement</span><span class="br0">(</span><span class="st0">'minute'</span><span class="br0">)</span>;
example.<span class="me1">timeDiff</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//1m:0s</span>
example.<span class="me1">decrement</span><span class="br0">(</span><span class="st0">'hour'</span><span class="br0">)</span>;
example.<span class="me1">timeDiff</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//1h:1m:0s</span>

example.<span class="me1">increment</span><span class="br0">(</span><span class="st0">'hour'</span>, <span class="nu0">2</span><span class="br0">)</span>;
example.<span class="me1">timeDiff</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//3h:1m:0s</span>
</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>string</em>) the compact representation of the differences in the times.</li>
      </ul>
      <h2 id="Date:timeDiffInWords"><a href="#Date:timeDiffInWords">Date Method: timeDiffInWords</a></h2>
      <h3 class="description">Syntax</h3>
      <pre class="javascript">date.<span class="me1">timeDiffInWords</span><span class="br0">(</span><span class="br0">[</span>otherDate<span class="br0">]</span><span class="br0">)</span>;

</pre>
      <h3>Arguments</h3>
      <ol>
        <li>otherDate - (<em>date</em>; optional) an optional date to use for the differential. Defaults to the current date/time.</li>
      </ol>
      <h3>Example</h3>
      <pre class="javascript"><span class="kw2">var</span> example = <span class="kw2">new</span> Date<span class="br0">(</span><span class="br0">)</span>;
example.<span class="me1">timeDiffInWords</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//less than a minute ago</span>

example.<span class="me1">decrement</span><span class="br0">(</span><span class="st0">'hour'</span><span class="br0">)</span>;
example.<span class="me1">timeDiffInWords</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//about an hour ago</span>
example.<span class="me1">increment</span><span class="br0">(</span><span class="st0">'hour'</span>, <span class="nu0">2</span><span class="br0">)</span>;
example.<span class="me1">timeDiffInWords</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//about an hour from now</span>

</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>string</em>) the friendly version of the duration since the date</li>
      </ul>
      <h3>Note</h3>
      <p>This method is now an alias for the old <em>Date.timeAgoInWords</em>.</p>
    </div>
  </div>
<script type="text/javascript" src="../../../assets/mootools-core-1.3.js"></script>
<script type="text/javascript" src="../../../assets/mootools-more-smoothscroll.js"></script>
<script type="text/javascript" src="../../../assets/doc-assist.js"></script>
</body>
</html>
